package com.dormitory.controller;


import com.dormitory.bean.UserBean;
import com.dormitory.httpHelper.HttpGetInfo;
import com.dormitory.httpHelper.HttpLogin;
import com.dormitory.httpHelper.HttpRegister;

import org.json.JSONException;

import java.io.IOException;
import java.util.List;

/**
 * Created by JHF on 2017/10/18.
 */

public class UserController {
    private static UserController _userController = null;
    public static UserController getInstance() {
        if(_userController == null) {
            _userController = new UserController();
        }
        return _userController;
    }

    public int checkUser(String name, String password, UserBean user) {
        try {
            return HttpLogin.loginByGet(name, password, user);
        } catch (Exception e) {
            e.printStackTrace();
            return 2;
        }
    }
    public int register(String name, String password, String dormitory, String telephone) {
        try {
            return HttpRegister.registerByGet(name, password, dormitory, telephone);
        } catch (Exception e) {
            e.printStackTrace();
            return 2;
        }
    }
    public List<UserBean> getMember(int dormitoryId) {
        try {
            return HttpGetInfo.getMember(dormitoryId);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
